package com.testing.class5;

import com.testing.web.WebKeywords;

import java.io.IOException;

/**
 * @Classname ShopAdminTest
 * @Description 类型说明
 * @Date 2022/10/12 20:06
 * @Created by 特斯汀Roy
 */
public class ShopAdminPage {
    public static void main(String[] args) throws IOException {
        WebKeywords web = new WebKeywords();
        web.open("chrome");
        web.visitWeb("http://www.testingedu.com.cn:8000/index.php/Admin");
        web.input("//input[@name='usename']", "admin");
        web.input("//input[@name='password']", "123456");
        web.input("//input[@name='vertify']", "1");
//        web.takeEleScreenShot("//img[@id='imgVerify']","vertify");
//        web.takeScreenShot("全屏");
        web.click("//input[@value='登录']");
        web.click("//a[tex()='商城']");

        //切换Iframe
        web.switchIframe("workspace");
        //添加商品
        web.click("//span[text()='添加商品']");
        web.saveDateParam("随机商品","VIP14测试商品","ddHHmmss");
        web.input("//input[@name='goods_name']","{随机商品}");
        web.click("//select[@id='cat_id']");
        web.selectByText("#cat_id", "服饰");
        web.halt("0.5");
        web.selectByText("#cat_id_2", "男装");
        web.halt("0.5");
        web.selectByText("#cat_id_3", "羽绒服");
        web.input("//input[@name='shop_price']","300");
        web.input("//input[@name='market_price']","500");
        //文件上传
        web.click("//input[contains(@title,'点击前方预览图可查看大图')]");
        web.switchIframe("//iframe[contains(@id,'layui')]");
        web.input("//div[text()='点击选择文件']/following-sibling::div[@id]/input","E:\\QSwork\\素材\\图片素材\\airtestLogo.jpg");
        web.halt("1");
        web.click("//div[text()='确定使用']");
        web.switchIframe("workspace");
        //选择是 包邮
        web.click("//label[text()='是' and @id]");
        web.click("//a[text()='确认提交']");
        //断言标准是第一个元素的商品名称是VIP13测试商品
        web.assertElementTextContains("//div[@id='flexigrid']//tr[1]/td[4]", "{随机商品}");
        web.assertDbExists("select * from tp_goods where goods_name = '{随机商品}'");
        web.halt("3");
        web.quit();

    }

}
